Godot 4.0: シグナルに引数ありの callable を connect するときは、bindで引数を渡す
Godot のシグナルに connect したい callableオブジェクトが、引数を必要とする場合にそれを指定する方法
Callable.bind(...) もしくは Callable.bindv(Array arguments) を使う
Callable bind ( ... ) vararg const
Returns a copy of this Callable with one or more arguments bound. When called, the bound arguments are passed after the arguments supplied by call.
Callable bindv ( Array arguments )
Returns a copy of this Callable with one or more arguments bound, reading them from an array. When called, the bound arguments are passed after the arguments supplied by call.
例:tween の finished シグナルで 引数を2つ必要とする callable に connect する場合
code:gd
tween.finished.connect(_tween_state_check.bind(tween, 1))
tween.finished.connect(_tween_state_check.bindv(tween, 2)) func _tween_state_check(tween: Tween, index: int):
pass